package com.pubinfo.passbook.data.quartz.task;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.pubinfo.passbook.common.service.request.tax.RequestTaxServer;
import com.pubinfo.passbook.data.service.InvoiceFilePackageInfoService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Slf4j
@DisallowConcurrentExecution //作业不并发
@Component
public class SyncTaxJob implements Job {
  @Resource
  RequestTaxServer taxServer;
  @Autowired
  InvoiceFilePackageInfoService invoiceFilePackageInfoService;
  
  @Override
  public void execute(JobExecutionContext context) {
    log.info("定时任务成功" + new Date());
    JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    taxServer.sync(dataMap.getString("task-id"));
    invoiceFilePackageInfoService.sync(dataMap.getString("task-id"));
  }
}